home *** CD-ROM | disk | FTP | other *** search
/ World of Education / World of Education.iso / world_p / pcshx10b.zip / PCSHX10B.EXE / UTILS.EXE / UTILDOCS.EXE / SED.H < prev    next >
Text File  |  1987-04-05  |  6KB  |  89 lines

  1. /* sed.h -- types and constants for the stream editor */
  2.  
  3. /* data area sizes used by both modules */
  4. #define MAXBUF          4096    /* current line buffer size             */
  5. #define MAXAPPENDS      20      /* maximum number of appends            */
  6. #define MAXTAGS         9       /* tagged patterns are \1 to \9         */
  7. #define MAXHOLD         MAXBUF  /* size of the hold space               */
  8. #define GENSIZ          MAXBUF  /* maximum genbuf size                  */
  9. #define MAXWBUF         1024    /* maximum word list buffer             */
  10. #define MAXIOBUF        16384   /* maximum input/output file buffer     */
  11. #define MAXCMDS         200     /* maximum number of compiled commands  */
  12. #define MAXLINES        256     /* max # numeric addresses to compile   */ 
  13.  
  14. /* constants for compiled-command representation */
  15. #define EQCMD   0x01    /* = -- print current line number               */
  16. #define ACMD    0x02    /* a -- append text after current line          */
  17. #define BCMD    0x03    /* b -- branch to label                         */
  18. #define CCMD    0x04    /* c -- change current line                     */
  19. #define DCMD    0x05    /* d -- delete all of pattern space             */
  20. #define CDCMD   0x06    /* D -- delete first line of pattern space      */
  21. #define GCMD    0x07    /* g -- copy hold space to pattern space        */
  22. #define CGCMD   0x08    /* G -- append hold space to pattern space      */
  23. #define HCMD    0x09    /* h -- copy pattern space to hold space        */
  24. #define CHCMD   0x0A    /* H -- append hold space to pattern space      */
  25. #define ICMD    0x0B    /* i -- insert text before current line         */
  26. #define LCMD    0x0C    /* l -- print pattern space in escaped form     */
  27. #define NCMD    0x0D    /* n -- get next line into pattern space        */
  28. #define CNCMD   0x0E    /* N -- append next line to pattern space       */
  29. #define PCMD    0x0F    /* p -- print pattern space to output           */
  30. #define CPCMD   0x10    /* P -- print first line of pattern space       */
  31. #define QCMD    0x11    /* q -- exit the stream editor                  */
  32. #define RCMD    0x12    /* r -- read in a file after current line       */
  33. #define SCMD    0x13    /* s -- regular-expression substitute           */
  34. #define TCMD    0x14    /* t -- branch on last substitute successful    */
  35. #define CTCMD   0x15    /* T -- branch on last substitute failed        */
  36. #define WCMD    0x16    /* w -- write pattern space to file             */
  37. #define CWCMD   0x17    /* W -- write first line of pattern space       */
  38. #define XCMD    0x18    /* x -- exhange pattern and hold spaces         */
  39. #define YCMD    0x19    /* y -- transliterate text                      */
  40.  
  41. struct  cmd_t                           /* compiled-command structure   */
  42. {
  43.         char    *addr1;                 /* first address for command    */
  44.         char    *addr2;                 /* second address for command   */
  45.         union
  46.         {
  47.                 char            *lhs;   /* s command lhs                */
  48.                 struct cmd_t    *link;  /* label link - branch          */
  49.         } u;
  50.         char    command;                /* command code                 */
  51.         char    *rhs;                   /* s command replacement string */
  52.         FILE    *fout;                  /* associated output file       */
  53.         struct                          /*                  descriptor  */
  54.         {
  55.                 unsigned allbut  : 1;   /* was negation specified?      */
  56.                 unsigned global  : 1;   /* was p postfix specified?     */
  57.                 unsigned print   : 2;   /* was g postfix specified?     */
  58.                 unsigned inrange : 1;   /* in an address range?         */
  59.                 unsigned igcase  : 1;   /* ignore case in selection ?   */
  60.         } flags;
  61. };
  62. typedef struct cmd_t    sedcmd;         /* use sedcmd for declarations  */
  63.  
  64. #define BAD     ((char *) -1)           /* guaranteed not a string ptr  */
  65.  
  66.  
  67. /* address and regular expression compiled-form markers */
  68. #define STAR    1        /* Kleene star to be ORed to other markers     */
  69. #define CCHR    2        /* non-newline character to be matched follows */
  70. #define CDOT    4        /* dot wild-card marker '.'                    */
  71. #define CCL     6        /* character class follows (16 bytes) '[]'     */
  72. #define CNL     8        /* match line start '^'                        */
  73. #define CDOL    10       /* match line end   '$'                        */
  74. #define CBWD    12       /* match word start '\<'                       */
  75. #define CEWD    14       /* match word end   '\>'                       */
  76. #define CBRA    16       /* tagged pattern start marker '\('            */
  77. #define CKET    18       /* tagged pattern end marker '\)'              */
  78. #define CBACK   20       /* backslash-digit pair marker '\d'            */
  79. #define CLNUM   22       /* numeric-address index follows 'ddd'         */
  80. #define CEND    24       /* symbol for end-of-source  '$'               */
  81. #define CEOF    26       /* end-of-field mark                           */
  82. #define CALF    28       /* alphanumeric   \a: one,  \A: one+ remaining */
  83. #define CLET    30       /* letters        \l: one,  \L: one+ remaining */
  84. #define CDIG    32       /* digits         \d: one,  \D: one+ remaining */
  85. #define CHEX    34       /* hexdigit       \h: one,  \H: one+ remaining */
  86. #define CSPS    36       /* space          \s: one,  \S: one+ remaining */
  87.  
  88. /* sed.h ends here */
  89.